package com.blockmeta.bbs.immodule.widget.msgview;

import android.content.Context;

import com.blockmeta.bbs.immodule.dao.ChatMessage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SuppotMsgViewType {

    public static final int UNSUPPORT_KEY = 9999;
    private static List<Integer> supportType;
    static {
        supportType = new ArrayList<>();
        supportType.add(ChatMessage.CONTENT_TYPE_NORMAL);
        supportType.add(ChatMessage.CONTENT_TYPE_NOTIFY);
        supportType.add(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_JPG);
        supportType.add(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_GIF);
        supportType.add(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_DOC);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_F10);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_KLINE);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_CARD);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_FORUMPOST);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_POST);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_ACTIVITY);
        supportType.add(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_GOODHING);
        supportType.add(ChatMessage.CONTENT_TYPE_HONGBAO);
        supportType.add(ChatMessage.CONTENT_TYPE_NONOTIFY);
    }

    public static boolean contain(int itemType) {
        return supportType.contains(itemType);
    }

    public Map<Integer, IMsgView> getSupportViews(Context mContext) {

        HashMap<Integer, IMsgView> msgViewMap = new HashMap<>(15);
        msgViewMap.put(UNSUPPORT_KEY, new UnsupportMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_NORMAL, new TextMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_NOTIFY, new SysMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_JPG, new ImageMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_GIF, new ImageMsgView(mContext));
        //其他文件都使用一种view先
        msgViewMap.put(ChatMessage.CONTENT_TYPE_ATTACHMENT * 100 + ChatMessage.TYPE_DOC, new FileShareMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_F10, new F10MsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_KLINE, new KlineMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_CARD, new CardMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_FORUMPOST, new ForumPostShareMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_POST, new PostShareMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_ACTIVITY, new ActivityShareMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_CUSTOM * 100 + ChatMessage.CUSTOM_TYPE_GOODHING, new GoodThingShareMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_HONGBAO, new HongbaoMsgView(mContext));
        msgViewMap.put(ChatMessage.CONTENT_TYPE_NONOTIFY, new SysMsgView(mContext));
        return msgViewMap;
    }
}
